package com.caine.androidtask.ls17;

import java.util.List;

import android.R;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.caine.androidtask.launcher.Utils;
import com.caine.androidtask.utils.XMLBeans;

public class Ls17 extends Activity {

	String PATH = "data.xml";
	List<XMLBeans> list;
	String startString = "pepole";
	ListView view;

	// Adapter adapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		view = new ListView(this);
		list = getList();
		view.setAdapter(new adapter1());
		setContentView(view);

	}

	public List<XMLBeans> getList() {
		return new DefaultXMLParse().getList(this, PATH);
	}

	public class adapter1 extends BaseAdapter {

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return list.size();
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return list.get(position);
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			// TODO Auto-generated method stub
			convertView = LayoutInflater.from(Ls17.this).inflate(
					R.layout.simple_list_item_1, parent, false);
			TextView tx = (TextView) convertView.findViewById(R.id.text1);
			tx.append("\n studentID : " + list.get(position).getFiledString_1());
			tx.append("\n sex : " + list.get(position).getFiledString_2());
			tx.append("\n size : " + list.get(position).getFiledString_3());
			tx.append("\n SDK version : "+Utils.getAndroidSDKVersion());
			tx.setClickable(true);
			tx.setFocusable(true);
			tx.setBackgroundColor(Color.GRAY);
			return convertView;
		}

	}
}
